package com.ruoyi.project.module.mvinfo.controller;

import java.util.List;

import com.ruoyi.project.module.categoryinfo.service.ICategoryinfoService;
import com.ruoyi.project.module.dicinfo.service.IDicinfoService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.module.mvinfo.domain.Mvinfo;
import com.ruoyi.project.module.mvinfo.service.IMvinfoService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.domain.AjaxResult;

/**
 * 电影 信息操作处理
 * 
 * @author ruoyi
 * @date 2018-11-11
 */
@Controller
@RequestMapping("/module/mvinfo")
public class MvinfoController extends BaseController
{
    private String prefix = "module/mvinfo";
	
	@Autowired
	private IMvinfoService mvinfoService;
	@Autowired
	private ICategoryinfoService categoryinfoService;
	@Autowired
	private IDicinfoService dicinfoService;
	@RequiresPermissions("module:mvinfo:view")
	@GetMapping()
	public String mvinfo(ModelMap map)
	{
		map.put("Lan",categoryinfoService.SelectLan());
		map.put("Type",categoryinfoService.SelectType());
		map.put("Name",categoryinfoService.SelectName());
	    return prefix + "/mvinfo";
	}
	
	/**
	 * 查询电影列表
	 */
	@RequiresPermissions("module:mvinfo:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(Mvinfo mvinfo)
	{
		startPage();
        List<Mvinfo> list = mvinfoService.selectMvinfoList(mvinfo);
		return getDataTable(list);
	}
	
	/**
	 * 新增电影
	 */
	@GetMapping("/add")
	public String add(ModelMap map)
	{
		map.put("Lan",categoryinfoService.SelectLan());
		map.put("Type",categoryinfoService.SelectType());
		map.put("Name",categoryinfoService.SelectName());
		return prefix + "/add";
	}
	
	/**
	 * 新增保存电影
	 */
	@RequiresPermissions("module:mvinfo:add")
	@Log(title = "电影", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(Mvinfo mvinfo)
	{		
		return toAjax(mvinfoService.insertMvinfo(mvinfo));
	}

	/**
	 * 修改电影
	 */
	@GetMapping("/edit/{mvId}")
	public String edit(@PathVariable("mvId") Integer mvId, ModelMap map)
	{
		Mvinfo mvinfo = mvinfoService.selectMvinfoById(mvId);
		map.put("Lan",categoryinfoService.SelectLan());
		map.put("Staues",dicinfoService.selectDicinfoList());
		map.put("Type",categoryinfoService.SelectType());
		map.put("Name",categoryinfoService.SelectName());
		map.put("mvinfo", mvinfo);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存电影
	 */
	@RequiresPermissions("module:mvinfo:edit")
	@Log(title = "电影", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(Mvinfo mvinfo)
	{		
		return toAjax(mvinfoService.updateMvinfo(mvinfo));
	}
	
	/**
	 * 删除电影
	 */
	@RequiresPermissions("module:mvinfo:remove")
	@Log(title = "电影", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(mvinfoService.deleteMvinfoByIds(ids));
	}
	
}
